package com.yungu.swift.socket.push.task;

import com.yungu.swift.constants.SocketConstant;
import com.yungu.swift.socket.component.ChannelKeeper;
import com.yungu.swift.socket.push.model.PushContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 管理后台消息推送
 */
public class AdminPushTask implements Runnable {

    private static final Logger logger = LoggerFactory.getLogger(AdminPushTask.class);

    private PushContent pushContent;

    public AdminPushTask(PushContent pushContent) {
        this.pushContent = pushContent;
    }

    @Override
    public void run() {
        try {
            logger.info("----[PUSH: ADMIN]-----Data >>:{}------", pushContent.getData());
            //消息发送
//            switch (pushContent.getOpCode()) {
//                //批量去重推送
//                case PushContent.NEW_JOIN_ORDER_TIP: {
//                    ChannelKeeper.batchSendMessageByPrefix(SocketConstant.PUSH_ADMIN_PREFIX_ORDER_NOTIFY, SocketConstant.PUSH_ADMIN_SEPARATOR, pushContent);
//                    break;
//                }
//                //全推
//                case PushContent.NEW_JOIN_ORDER_CALL: {
//                    ChannelKeeper.batchSendMessageAllByPrefix(SocketConstant.PUSH_ADMIN_PREFIX_ORDER_CALL, pushContent);
//                    break;
//                }
//                default:
//                    ChannelKeeper.batchSendMessageAllByPrefix(SocketConstant.PUSH_ADMIN_ALL_USER, pushContent);
//                    break;
//            }
            ChannelKeeper.batchSendMessageAllByPrefix(SocketConstant.PUSH_ADMIN_ALL_USER, pushContent);

        } catch (Exception e) {
            logger.error("--------------- [PUSH: ADMIN] send msg error -------------", e);
        }
    }

}
